package com.bdqn.appjob.tools;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

///**
// * @author Kevin
// */
@Configuration
@EnableSwagger2
//@EnableWebMvc
public class SwaggerConfig {

    //配置了Swagger的Docket的Bean实例
    @Bean
    public Docket api() {
       /* return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.any())
                .build()
                .apiInfo(apiInfo());*/
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .groupName("涛哥")
                .select()
                //basePackage指定要扫描的包
                .apis(RequestHandlerSelectors.basePackage("com.bdqn.appjob.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("涛哥的集成swagger的接口测试")
                .description("知世俗而不世俗")
                .termsOfServiceUrl("https://i.csdn.net/#/uc/profile")
                .contact(new Contact("涛哥项目组", "http://localhost:8080/swagger-ui.html", "2751352802@qq.com"))
                .version("v1.0.0")
                .build();
    }

    @Bean
    public Docket docket1(){
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("其他人");
    }

}